package com.baor.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baor.base.util.R;
import com.baor.dao.MovieDao;
import com.baor.domain.MovieVO;
import com.baor.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class MovieServiceImpl implements MovieService {
    @Autowired
    private MovieDao movieDao;

    @Override
    public R movieList(Map<String, Object> params) {
        Page page = new Page();
        page.setCurrent((int)params.get("pageIndex"));
        page.setSize((int)params.get("pageSize"));
        IPage<MovieVO> movieVOIPage = this.movieDao.selectPage(page,null);
        Map<String,Object> map = new HashMap<>();
        map.put("totalSize",movieVOIPage.getTotal());
        map.put("movieList",movieVOIPage.getRecords());
        return R.ok(map);
    }

    @Override
    public MovieVO movieInfo(int movieID) {
        MovieVO movieVO = this.movieDao.selectById(1);
        return movieVO;
    }
}
